package day05;
import java.util.Arrays;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {

        /*
        //1)
        Scanner scan = new Scanner(System.in);
        int score = 0;
        for (int i = 1;i<=9;i++){
            int a = (int) (Math.random()*100);
            int b = (int) (Math.random()*100);
            int result = a+b;
            System.out.println("("+i+")"+a+"+"+b+"=?");
            int answer = scan.nextInt();
            if (answer==result){
                System.out.println("答对了！");
                score +=10;
            }else {
                System.out.println("答错了！");
            }
        }
        System.out.println("总分为："+score);



        //2)
        for (int num = 1;num<=9;num++){
            for (int i = 1;i<=num;i++){
                System.out.print(i+"*"+num+"="+i*num+"\t");
            }
            System.out.println();

        }

         */
        /*

        //3)
        int[] arr = new int[10];
        int[] arr1 = new  int[23];


        //4)
        int[] arr2 = new int[3];
        int[] arr3 = {4,5,9};
        int[] arr4 = new int[]{4,5,9};

         */



        /*
        //5)
        int[] arr = new int[3];
        System.out.println(arr.length);
        arr[0] = 100;
        arr[1] = 200;
        arr[2] = 300;
        System.out.println(arr[arr.length-1]);
        //arr[3] = 400;运行时发生数组下标越界

         */


        /*
        //6)
        int[] arr = new int[10];
        for (int i =0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);

        }

         */



        /*
        //7)
        int[] arr = new int[10];
        for (int i = 0;i<arr.length;i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.println(arr[i]);
        }

        int max = arr[0];
        for (int i = 1;i<arr.length;i++){
            if (arr[i]>max){
                max = arr[i];
            }
        }
            System.out.println("最大值为："+max);

         */




        /*
        //8)
        int[] arr = new int[10];
        for (int i =0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);

        }
        Arrays.sort(arr);
        System.out.println("排序后:");
        for (int i = 0;i<arr.length;i++){
            System.out.println(arr[i]);

        }
        System.out.println("倒着输出:");
        for (int i =arr.length-1; i>=0;i--){
            System.out.println(arr[i]);

        }

         */







        /*
        //1)
        Scanner scan = new Scanner(System.in);
        int score = 0;
        for (int i = 1;i<=10;i++){
            int a = (int) (Math.random()*100);
            int b = (int) (Math.random()*100);
            int result = a+b;
            System.out.println("("+i+")"+a+"+"+b+"=?");
            System.out.println("算吧！");
            int answer = scan.nextInt();
            if (answer==result){
                System.out.println("答对了！");
                score +=10;
            }else {
                System.out.println("答错了！");
            }
            System.out.println("总分为："+score);
        }

         */


        /*
        //2)
        for (int num = 1;num<=9;num++){
            for (int i =1;i<=num;i++){
                System.out.print(i+"*"+num+"="+i*num+"\t");
            }
            System.out.println();
        }

         */
        /*
        //3)
        int[] arr = new int[10];
        int[] arr2 = new int[50];

         */

        /*
        //4)
        int[] arr = new int[3];
        int[] arr2 = {4,5,6};
        int[] arr3 = new int[]{4,5,6};

         */




        /*
        //5)
        int[] arr = new int[3];
        System.out.println(arr.length);
        arr[0] = 100;
        arr[1] = 200;
        arr[2] = 300;
        System.out.println(arr[arr.length-1]);
        //arr[3] = 400;运行时发生数组下标越界

         */





        /*
        //6)
        int[] arr = new int[10];
        for (int i = 0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);
        }

         */





        /*
        //7)
        int[] arr = new int[10];
        for (int i = 0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);
        }
        int max = arr[0];
        for (int i = 1;i<arr.length;i++){
            if (arr[i]>max){
                max = arr[i];

            }
        }
        System.out.println("最大值为："+max);

         */


        //8)
        int[] arr = new int[10];
        for (int i = 0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);
        }
        Arrays.sort(arr);

        System.out.println("排序后：");
        for (int i =0;i<arr.length;i++){
            System.out.println(arr[i]);

        }
        System.out.println("倒着输出：");
        for (int i=arr.length-1;i>=0;i--){
            System.out.println(arr[i]);

        }
















    }



















}

